#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

void insert_sort(vector<int> &num)
{
	int n = num.size();
	for (int i = 1, j = 0, key = 0; i < n; i++) {
		key = num[i];
		j = i - 1;
		while (j >= 0 && key < num[j]) {
			num[j + 1] = num[j];
			j--;
		}
		num[j + 1] = key;
	}
}

void merge_sort(vector<int> &num, int l, int r)
{
	if (l >= r) {
		return;
	}
	int mid = (l + r) >> 1;
	merge_sort(num, l, mid);
	merge_sort(num, mid + 1, r);

	int ln = mid - l + 1;
	int rn = r - mid;
	vector<int> larr(ln + 1), rarr(rn + 1);
	for (int i = 0; i < ln; i++) {
		larr[i] = num[l + i];
	}
	larr[ln] = INT32_MAX;
	for (int i = 0; i < rn; i++) {
		rarr[i] = num[mid + 1 + i];
	}
	rarr[rn] = INT32_MAX;

	int ll = 0, rr = 0;
	for (int k = l; k <= r; k++) {
		if (larr[ll] <= rarr[rr]) {
			num[k] = larr[ll];
			ll++;
		} else {
			num[k] = rarr[rr];
			rr++;
		}
	}
}

int partion(vector<int> &num, int l, int r)
{
	int key = num[r];
	int i = l - 1;
	for (int j = l; j < r; j++) {
		if (num[j] <= key) {
			i++;
			swap(num[i], num[j]);
		}
	}
	swap(num[i + 1], num[r]);
	return i + 1;
}

void quick_sort(vector<int> &num, int l, int r)
{
	if (l < r) {
		int p = partion(num, l, r);
		quick_sort(num, l, p - 1);
		quick_sort(num, p + 1, r);
	}
}

pair<int, int> partion2(vector<int> &num, int l, int r)
{
	int mid = (l + r) / 2;
	int key = num[mid];
	swap(num[l], num[mid]);

	int i = l - 1, k = l;
	for (int j = l + 1; j <= r; j++) {
		if (num[j] < key) {
			i++;
			k++;
			swap(num[i], num[j]);
			swap(num[k], num[j]);
		} else if (num[j] == key) {
			k++;
			swap(num[j], num[k]);
		}
	}
	return { i, k };
}

pair<int, int> tpartion2(vector<int> &num, int l, int r)
{
	int mid = (l + r) / 2;
	int key = num[mid];

	int i = l - 1, k = l - 1;
	for (int j = l; j <= r; j++) {
		if (num[j] < key) {
			i++;
			k++;
			swap(num[i], num[j]);
			if (i != k) {
				swap(num[k], num[j]);
			}
		} else if (num[j] == key) {
			k++;
			swap(num[j], num[k]);
		}
	}
	return { i, k };
}

void quick_sort2(vector<int> &num, int l, int r)
{
	if (l < r) {
		auto p = tpartion2(num, l, r);
		quick_sort2(num, l, p.first);
		quick_sort2(num, p.second + 1, r);
	}
}

pair<int, int> tpartion(vector<int> &num, int l, int r)
{
	int mid = (l + r) / 2;
	int key = num[mid];

	int i = l - 1, k = r + 1;
	for (int j = l; j < k;) {
		if (num[j] < key) {
			i++;
			swap(num[i], num[j]);
                        j++;
		} else if (num[j] > key) {
			k--;
			swap(num[j], num[k]);
		}else{
                        j++;
                }
	}
	return { i, k };
}

void tquick_sort(vector<int> &num, int l, int r)
{
	if (l < r) {
		auto p = tpartion(num, l, r);
		tquick_sort(num, l, p.first);
		tquick_sort(num, p.second, r);
	}
}

int main()
{
	int n = 0;
	cin >> n;
	vector<int> num(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> num[i];
	}
	//insert_sort(num);
	//merge_sort(num, 0, n - 1);
	//srand(time(nullptr));
	//quick_sort2(num, 0, n - 1);
        tquick_sort(num, 0, n - 1);

	for (auto v : num) {
		cout << v << " ";
	}
	cout << endl;

	return 0;
}